﻿// See https://aka.ms/new-console-template for more information
using FluentRestSharp.Impl;
using FluentRestSharp.Interface;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using System;

Console.WriteLine("Hello, World!");
ServiceCollection serices = new ServiceCollection();
serices.AddTransient(typeof(IFluentClient), typeof(FluentClient));
var serviceProvider = serices.BuildServiceProvider();
var fastClient= serviceProvider.GetService<IFluentClient>();
//https://wxmini.api.bjadks.com/
var result= serviceProvider.GetService<IFluentClient>()
    .BuildClient("http://localhost:15838/Test/GetToken")
    .Post()
    .AddHeader("User-Agent", "PostmanRuntime/7.29.2")
    .AddBodyData(new Dictionary<string, string>()
    {
       {"app_key","21877caa62161e5" },
       {"app_secret","b798c7b305004ab6d08cf13df0632402" }
    })
    .BuildRequest()
    .GetResponse();
           
//string content = fastClient
//    .BuildRequest("")
//    .Get("https://localhost:5001/api/User/Login")
//    .SetQueryParameter("Account", "admin")
//    .SetQueryParameter("pwd", "123456")
//    .ToClient()
//    .GetContent();
//JObject obj=JObject.Parse(content);
//string token = obj.SelectToken("model").SelectToken("RequestToken").ToString();
//string content1 = serviceProvider.GetService<IFastRequest>().Post("https://localhost:5001/api/user")
//    .SetBodyData("{\"UserName\":\"测试测试\",\"UserAccount\":\"admin999\",\"UserPassWord\":\"123456\",\"UserSex\":\"0\",\"UserPhone\":\"345354\",\"UserRole\":\"0\",\"IdNumber\":\"453453\",\"OrgId\":[1,2],\"CreateBy\":1}")
//    .SetHeader("content-type", "application/json; charset=utf-8")
//    .SetHeader("Authorization", $"Bearer {token}")
//    .ToClient()
//    .GetContent();

Console.WriteLine("Hello, World!");